<div class="forum-path"> 
<?php echo $this->Html->link('Project', array('controller' => 'projects', 'action' => 'view',$projectId)); ?> » 
<?php echo $this->Html->link('Forum index', array('controller' => 'forums', 'action' => 'index',$projectId)); ?> » 
<?php echo $this->Html->link($forumName, array('controller' => 'forums', 'action' => 'view', $forumId)); ?> 
</div>
<div class="forum-index">
    <table class="table table-bordered">
    <thead>
    <tr style="
        background-color: rgba(44, 43, 43, 0.79);
        color: whitesmoke;
    ">
        <th colspan="2" style="text-align:center">Topic</th>
        <th style="text-align:center">Author</th>
        <th style="text-align:center">Replies</th>
        <th style="text-align:center">Views</th>
        <th style="text-align:center">Last post</th>
    </tr>
    </thead>
    <tbody>
  
    <?php 
  	$i = 0;
  	if(!empty($topics)) { foreach($topics as $topic): 
  	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
  ?>
    <tr<?php echo $class; ?>>
      <td colspan="2"><?php echo $this->Html->link($topic['ForumTopic']['subject'], 
					array('controller' => 'forums', 'action' => 'topic', $topic['ForumTopic']['id'], $forumId)); ?></td>
      <td style="text-align:center"><?php echo $this->Html->link($topic['User']['username'], 
					array('controller' => 'users', 'action' => 'profile', $topic['User']['username'])); ?></td>
      <td style="text-align:center"><?php echo $topic['ForumTopic']['replies']; ?></td>
      <td style="text-align:center"><?php echo $topic['ForumTopic']['views']; ?></td>
      <td style="text-align:center">
	  	<?php 
			echo $this->Html->link('»»»', 
				array(
					'controller' => 'forums', 
					'action' => 'topic', 
					$topic['ForumTopic']['id'], 
					$forumId,
					'page:' . $topic['ForumTopic']['last_post_page'].
					'#' . $topic['ForumTopic']['last_post_id']
				)
			); 
		?>
                    <br />
        <?php echo $this->Time->format('d.m.Y H:i', $topic['ForumTopic']['last_post_created']); ?> | 
		<?php echo $this->Html->link($topic['ForumTopic']['last_post_username'], 
					array('controller' => 'users', 'action' => 'profile', $topic['ForumTopic']['last_post_username'])); ?></td>
    </tr>
    <?php endforeach; }?>
    
    </tbody>
  </table>
  <div class="paging">
    <?php 
		$this->Paginator->options(array(
				'url' => $this->passedArgs,
			)
		);
		echo $this->Paginator->prev("« back", array(), null, array('class'=>'disabled'));
		echo $this->Paginator->numbers(array('before' => '', 'after' => '', 'separator' => ''));
		echo $this->Paginator->next('forward »', array(), null, array('class'=>'disabled'));
	?>
  </div>
  <p align="right">
    <?php echo $this->Html->link('New topic', array('controller' => 'forums', 'action' => 'newtopic', $forumId),array('class'=>'btn btn-inverse')); ?>
    
  </p>
  
</div>
